__author__ = 'Pierre Moermans'

from django.http import HttpResponse
from django.utils import simplejson
import uuid

def __buildMessage(type, text):
    return HttpResponse(simplejson.dumps({
        'message': {
            'type': type,
            'text': text
        }
    }),'application/javascript')

def buildError(text, uid):
    return __buildMessage("error", str(uid) + ": " + text)

def buildWarning(text):
    return __buildMessage("warning", text)

def buildInfo(text):
    return __buildMessage("info", text)

def msgWithUUID(uid, message):
    return uid + ": " + message